#!/bin/bash

#set -x

##  Arguments:
##  stop  - stops cimom and kills processes
##  start - starts HSC by calling startup scripts
##  start debug - set debug log flag, start rmiregistry, switch sniacimom.jar.

function checkVersion {
   typeset -i pv1
   typeset -i pv2
   typeset -i pr
   typeset -i v1
   typeset -i v2
   typeset -i r
   pv1=0
   pv2=0
   pr=0
   r=`rpm -q -i IBMhsc.coreserver|grep Release| tail -1|cut -d ':' -f 2 | cut -d ' ' -f 2`
   v1=`rpm -q -i IBMhsc.coreserver|grep Version| tail -1|cut -d ':' -f 2 | cut -d ' ' -f 2 | cut -d '.' -f 1`
   v2=`rpm -q -i IBMhsc.coreserver|grep Version| tail -1|cut -d ':' -f 2 | cut -d ' ' -f 2 | cut -d '.' -f 2`
   if [[ $pv1 -eq 0  ||  $v1 -gt $pv1 ]]
   then
        pv1=v1
   fi
   if [[ $pv2 -eq 0  ||  $v2 -gt $pv2 ]]
   then
        pv2=v2
   fi 
   if [[ $pr -eq 0  ||  $r -gt $pr ]]
   then
        pr=r
   fi 
   echo " Version: "$pv1
   echo " Release: "$pr"."$pv2
}

if [ "$2" = "" ]
then
  FLAG=false
else
  FLAG=$2
fi
case $1 in
version )
  checkVersion
  cat /opt/hsc/data/version
;;

"" )
 echo        hsc version - Show HMC Version
;;

esac
